﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WindChill
{
    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void btnCalc_Click(object sender, RoutedEventArgs e)
        {
            double dTemp, dWindSpeed;

            Double.TryParse(txtTemp.Text, out dTemp);
            Double.TryParse(txtWindSpeed.Text, out dWindSpeed);

            if (dTemp > 10)
            {
                MessageBox.Show("Die Temperatur darf nicht über 10°C betragen!", "", MessageBoxButton.OK);
                txtTemp.SelectAll();
            }
            else if (dWindSpeed < 10)
            {
                MessageBox.Show("Die Windgeschwindigkeit muss mindestens 10km/h betragen!");
                txtWindSpeed.SelectAll();
            }
            else
            {
                double dWCT = 13.12 + 0.6215 * dTemp - 11.37 * Math.Pow(dWindSpeed, 0.16) + 0.3965 * dTemp * Math.Pow(dWindSpeed, 0.16);
                lblWindChill.Content = "Die Windchilltemperatur beträgt " + Math.Round(dWCT, 2) + "°C";
                txtTemp.SelectAll();
            }
            

        }
    }
}
